// 公共，私有与受保护的修饰符
// 默认为 public
// 当成员被标记成 private时，它就不能在声明它的类的外部访问
//protected修饰符与 private修饰符的行为很相似，但有一点不同， protected成员在派生类中仍然可以访问
class Animal {
    move(distanceInMeters: number = 0) {
        console.log(`Animal moved ${distanceInMeters}m.`);
    }
}

class Dog extends Animal {
    bark() {
        console.log("Woof! Woof!");
    }
}

const dog = new Dog();
dog.bark();
dog.move(10);
dog.bark();

// 你可以使用 readonly关键字将属性设置为只读的。 只读属性必须在声明时或构造函数里被初始化。
class Octopus {
    readonly name: string;
    readonly numberOfLegs: number = 8;
    constructor(theName: string) {
        this.name = theName;
    }
}

//静态属性
class Grid {
    static origin = { x: 0, y: 0 };
    scale: number;
    constructor(scale: number) {
        this.scale = scale;
    }
    static distanceFromOrigin(point: { x: number; y: number }) {
        let xDist = point.x - Grid.origin.x;
        let yDist = point.y - Grid.origin.y;
    }
}

// 抽象类
abstract class Department {
    name: string;
    constructor(name: string) {
        this.name = name;
    }
    printName(): void {
        console.log("Department name: " + this.name);
    }
    abstract printMeeting(): void; // 必须在派生类中实现
}
